<?php
/**
 *
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Config
 * @since         CakePHP(tm) v 2.0.0
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
 */

/**
 * This is email configuration file.
 *
 * Use it to configure email transports of CakePHP.
 *
 * Email configuration class.
 * You can specify multiple configurations for production, development and testing.
 *
 * transport => The name of a supported transport; valid options are as follows:
 *  Mail - Send using PHP mail function
 *  Smtp - Send using SMTP
 *  Debug - Do not send the email, just return the result
 *
 * You can add custom transports (or override existing transports) by adding the
 * appropriate file to app/Network/Email. Transports should be named 'YourTransport.php',
 * where 'Your' is the name of the transport.
 *
 * from =>
 * The origin email. See CakeEmail::from() about the valid values
 *
 */
class EmailConfig {

	public $default = array(
		'transport' => 'Mail',
		'from' => 'you@localhost',
		//'charset' => 'utf-8',
		//'headerCharset' => 'utf-8',
	);

	public $smtp = array(
		'transport' => 'Smtp',
		'from' => array('tien@bliss-interactive.net' => 'My Site'),
		'host' => 'smtp.gmail.com',
		'port' => 465,
		'timeout' => 30,
		'username' => 'tien@bliss-interactive.net',
		'password' => 'phamhongtien510',
		'client' => null,
		'log' => false,
		'charset' => 'utf-8',
		'headerCharset' => 'utf-8',
        'ssl' => true,
        'emailFormat' => 'html',
	);
	
	public $fast = array(
		'from' => 'you@localhost',
		'sender' => null,
		'to' => null,
		'cc' => null,
		'bcc' => null,
		'replyTo' => null,
		'readReceipt' => null,
		'returnPath' => null,
		'messageId' => true,
		'subject' => null,
		'message' => null,
		'headers' => null,
		'viewRender' => null,
		'template' => false,
		'layout' => false,
		'viewVars' => null,
		'attachments' => null,
		'emailFormat' => null,
		'transport' => 'Smtp',
		'host' => 'localhost',
		'port' => 25,
		'timeout' => 30,
		'username' => 'user',
		'password' => 'secret',
		'client' => null,
		'log' => true,
		//'charset' => 'utf-8',
		//'headerCharset' => 'utf-8',
	);
	function __construct(){
		$this->smtp = array(
							'transport' => 'Smtp',
							'from' => Configure::read('SMTP_Config.from'),
							'host' => Configure::read('SMTP_Config.host'),
							'port' => Configure::read('SMTP_Config.port'),
							'timeout' => Configure::read('SMTP_Config.timeout'),
							'username' => Configure::read('SMTP_Config.username'),
							'password' => Configure::read('SMTP_Config.password'),
							'client' => null,
							'log' => false,
							'charset' => 'utf-8',
							'headerCharset' => 'utf-8',
						);		
	}

}
/*
//send mail code demo in controler
$this->language = 'nl';
$mailer = new CakeEmail('smtp');
$email_from = $this->language == 'nl' ? "digitaldays@goudengids.be":"journeesdigitales@pagesdor.be";
$email_reply_to = $this->language == 'nl' ? "info@digitaldays.be":"info@journeesdigitales.be";
$email_sender_name = $this->language == 'nl' ? "Digital Days":"Journées Digitales";

$email_subject = $this->language == 'nl' ? "Fijn dat u naar de Digital Days komt!":"Cool ! Vous venez aux Journées Digitales !";
	
$email_to = 'tri@bliss-interactive.net';	
$email_receiver_name = 'tester';

$view_link = Router::url(array('language' => $this->language, 'controller' => 'homepage', 'action' => 'view_email', 'confirmation','name','Date','City'), true);
		
$send_status = "";		
if(!empty($email_to))
{
	$mailer->template('content', 'template')->emailFormat('html')
		->subject($email_subject)
		->viewVars(array('data' => array('language'=>$this->language,'mail_template'=>'confirmation','email_vars'=>array('view_link'=>$view_link,'name'=>'@name@'))))
		->from(array($email_from => $email_sender_name))
		->replyTo(array($email_reply_to => $email_sender_name))
		->to(array($email_to => $email_receiver_name));
	if ( $mailer->send() )
	{
		$send_status = "ok";
	}else{
		$send_status = "Fail";
	}
}	
exit($send_status);
*/

/*//add view to show email
public function view_email($mail_template='',$name='',$event_date='',$event_city=''){
	$this->layout = 'ajax';
	$data = array('language'=>$this->language,'mail_template'=>$mail_template,'email_vars'=>array('view_link'=>'#','name'=>$name,'event_date'=>$event_date,'event_city'=>$event_city));
	$this->set('data', $data);
	$this->render('/Emails/html/content');
}*/